import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path';  // node 自带的路径管理插件
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),

  ],
  resolve: {
    alias: {
      // 给 src 目录设置 @ 别名
      "@": path.resolve(__dirname, "src"),
      // 给 components 设置 @components 别名
      "@components": path.resolve(__dirname, 'src/components')
    }
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://nocat.life:3012',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  }
})